﻿using ESRI.ArcGIS.ArcMapUI;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Framework;
using ESRI.ArcGIS.SystemUI;
using System.Windows.Forms;

namespace Swsk33.ArcMapDevelop
{
	/// <summary>
	/// 显示激活数据框中所有图层的名称
	/// </summary>
	public class GetLayerName : ICommand
	{
		/// <summary>
		/// ArcMap钩子对象
		/// </summary>
		private IApplication arcmapObject;

		/// <summary>
		/// 按钮图标
		/// </summary>
		public int Bitmap
		{
			get;
			set;
		}

		/// <summary>
		/// 按钮名
		/// </summary>
		public string Caption
		{
			get { return "获取图层名称"; }
		}

		/// <summary>
		/// 工具集分类名
		/// </summary>
		public string Category
		{
			get { return "swsk33"; }
		}

		public bool Checked
		{
			get { return false; }
		}

		public bool Enabled
		{
			get { return true; }
		}

		public int HelpContextID
		{
			get;
			set;
		}

		public string HelpFile
		{
			get;
			set;
		}

		public string Message
		{
			get { return "获取图层名称"; }
		}

		public string Name
		{
			get { return "获取图层名"; }
		}

		public void OnClick()
		{
			IMxDocument mxDocument = (IMxDocument)arcmapObject.Document;
			IMap map = mxDocument.FocusMap;
			for (int i = 0; i < map.LayerCount; i++)
			{
				ILayer layer = map.get_Layer(i);
				MessageBox.Show(layer.Name);
			}
		}

		public void OnCreate(object Hook)
		{
			arcmapObject = (IApplication)Hook;
		}

		public string Tooltip
		{
			get { return "获取图层的名称"; }
		}
	}
}